package com.xs.ahoi.hcxs.model;

import com.xs.ahoi.hcxs.utils.FileUtil;
import com.xs.ahoi.hcxs.utils.ObjectUtils;

/**
 * author: ahoi
 * date: 2018/6/21 12:03
 * description:书籍
 */
public class Book {

    private int id;
    private String path;
    private String name;
    private long totalLenth;
    private long lastReadTime;
    private int lastReadPosition;
    // 置顶时间，最后置顶的在最上面
    private long setTopTime;

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getPath() {
        return path;
    }

    public void setPath(String path) {
        this.path = path;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public long getTotalLenth() {
        return totalLenth;
    }

    public void setTotalLenth(long totalLenth) {
        this.totalLenth = totalLenth;
    }

    public long getLastReadTime() {
        return lastReadTime;
    }

    public void setLastReadTime(long lastReadTime) {
        this.lastReadTime = lastReadTime;
    }

    public long getSetTopTime() {
        return setTopTime;
    }

    public void setSetTopTime(long setTopTime) {
        this.setTopTime = setTopTime;
    }

    public int getLastReadPosition() {
        return lastReadPosition;
    }

    public void setLastReadPosition(int lastReadPosition) {
        this.lastReadPosition = lastReadPosition;
    }

    // 获取阅读进度
    public String getPercent() {
        if (lastReadPosition < 0) {
            return "未读";
        }
        if (totalLenth == 0) {
            return "0.00%";
        }
        return ObjectUtils.toFix(lastReadPosition * 100f / totalLenth, 2) + "%";
    }

    // 获取文件大小
    public String getSize() {
        return FileUtil.byteToSize(this.totalLenth);
    }
}
